<?php
namespace Gotcha\Core\Components\Localization {
    use Gotcha\Core\Components\DTO\AppConfig;
    use Gotcha\Core\Components\Localization\Interfaces\ICultureInfo;

    class CultureInfo implements ICultureInfo {
        protected $_DTOAppConfig;

        public $decimal;
        public $currency;
        public $percent;
        public $scientific;
        public $spellout;
        public $ordinal;
        public $duration;

        public $collator;
        public $messageFormatter;


        public function __construct(
            AppConfig $DTOAppConfig
        ) {
            $this->_DTOAppConfig = $DTOAppConfig;
        }

        public function setDefaultLocale()
        {
            \Locale::setDefault($this->_DTOAppConfig->defaultCulture);
        }

        public function setNumberFormatter()
        {
            $this->decimal = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
            $this->currency = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::CURRENCY);
            $this->percent = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::PERCENT);
            $this->scientific = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::SCIENTIFIC);
            $this->spellout = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::SPELLOUT);
            $this->ordinal = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::ORDINAL);
            $this->duration = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DURATION);
        }

        public function setCollator()
        {
            $this->collator = new \Collator(\Locale::getDefault());
        }
    }
}

